import request from '@/utils/request'
import qs from 'qs'


// 获取餐桌全部位置selectItem
export function deskRoomSelectItem() {
  return request({
    url: '/merchant/desk_room/select_item',
    method: 'get',
    params: {
      storeId: sessionStorage.getItem('storeId')
    }
  })
}

// 获取位置列表
export function deskRoomList() {
  return request({
    url: '/merchant/desk_room/list',
    method: 'get',
    params: {
      storeId: sessionStorage.getItem('storeId')
    }
  })
}

// 添加位置
export function deskRoomAdd(data) {
  return request({
    url: '/merchant/desk_room/save',
    method: 'post',
    data: qs.stringify(
      data
    )
  })
}

// 修改位置
export function deskRoomUpdate(data) {
  return request({
    url: '/merchant/desk_room/update',
    method: 'post',
    data: qs.stringify(
      data
    )
  })
}

// 删除位置
export function deskRoomLogicalDel(ids) {
  return request({
    url: '/merchant/desk_room/logical_del',
    method: 'post',
    data: qs.stringify({
      ids,
    }, {indices: false})
  })
}

// 获取桌形列表
export function deskTypeList() {
  return request({
    url: '/merchant/desk_type/list',
    method: 'get',
    params: {
      storeId: sessionStorage.getItem('storeId')
    }
  })
}

// 添加桌形
export function deskTypeAdd(deskType) {
  return request({
    url: '/merchant/desk_type/save',
    method: 'post',
    data: qs.stringify(
      deskType
    )
  })
}

// 修改桌形
export function deskTypeUpdate(deskType) {
  return request({
    url: '/merchant/desk_type/update',
    method: 'post',
    data: qs.stringify(
      deskType
    )
  })
}

// 删除桌形
export function deskTypeLogicalDel(ids) {
  return request({
    url: '/merchant/desk_type/logical_del',
    method: 'post',
    data: qs.stringify({
      ids,
    }, {indices: false})
  })
}

// 释放桌形
export function deskTypeLogicalrelese(ids) {
  return request({
    url: '/merchant/desk/release_desks',
    method: 'post',
    data: qs.stringify({
      ids,
    }, {indices: false})
  })
}

// 获取餐桌全部桌形selectItem
export function deskTypeSelectItem() {
  return request({
    url: '/merchant/desk_type/select_item',
    method: 'get',
    params: {
      storeId: sessionStorage.getItem('storeId')
    }
  })
}


// 获取餐桌列表
export function deskList(pageNumber, pageSize, data) {
  return request({
    url: '/merchant/desk/list_rewrite',
    method: 'get',
    params: {
      pageNumber,
      pageSize,
      deskRoomId: data.deskRoomId,
      deskTypeId: data.deskTypeId,
      status: data.status,
      storeId: sessionStorage.getItem('storeId')
    }
  })
}

// 添加餐桌
export function deskAdd(desk) {
  console.log(desk);
  return request({
    url: '/merchant/desk/save_rewrite',
    method: 'post',
    data: qs.stringify(
      desk
    )
  })
}

// 修改餐桌
export function deskUpdate(desk) {
  console.log(desk);
  return request({
    url: '/merchant/desk/update',
    method: 'post',
    data: qs.stringify(
      desk
    )
  })
}

// 删除餐桌
export function deskLogicalDel(ids) {
  return request({
    url: '/merchant/desk/logical_del',
    method: 'post',
    data: qs.stringify({
      ids,
    }, {indices: false})
  })
}


// 获取餐桌茶位费
// export function deskTeaChargeQuery () {
//   return request({
//     url: '/merchant/tea_charge/find_one',
//     method: 'get'
//   })
// }

// 修改餐桌茶位费
export function deskTeaChargeUpdate(id, money) {
  return request({
    url: '/merchant/tea_charge/update',
    method: 'post',
    data: qs.stringify({
      id: id,
      money: money
    }, {indices: false})
  })
}

// 获取餐桌茶位费
export function getStoreTeaPrice() {
  return request({
    url: '/merchant/tea_charge/find_by_store_id',
    method: 'get',
    params: {
      id: sessionStorage.getItem('storeId'),
    }
  })
}

// 修改餐桌茶位费
export function setStoreTeaPrice(id, val) {
  // console.log(sessionStorage.getItem('storeId'));
  // console.log(val);
  return request({
    url: '/merchant/tea_charge/update',
    method: 'post',
    data: qs.stringify({
      id: id,//茶位id
      money: val //茶位费
    }, {indices: false})
  })
}

